<template>
	<view style="min-height: 100vh;background: rgba(241, 241, 241, 0.46);">
		<!-- shareLogshareLog -->
		<view class="" style="background: #fff;margin: 10rpx 0 20rpx 0;padding: 30rpx 0;display: flex;justify-content: center;flex-direction: column;" v-for="(item,index) in list" :key="index">
			<view class="" style="display: flex;align-items: center;padding: 0 30rpx;">
				<image v-if="item.user && item.user.avatar" :src="info.app.cdnurl+item.user.avatar" style="width: 50rpx;height: 50rpx;border-radius: 50%;"></image>
				<view class="" v-if="item.user && item.user.nickname" style="font-size: 26rpx;margin-left: 10rpx;color: #7f7aa5;">{{item.user.nickname}}</view>
			</view>
			<view class="" style="display: flex;align-items: center;justify-content: center;margin-top: 20rpx;">
			
				<view class="" style="width:85%;">
					<view class="" style="background:rgba(241, 241, 241, 0.46);">
						<view class="" style="font-size: 24rpx;color: #333333;">{{item.ext.memo}}</view>
					</view>
					<view class="" style="color: #c8c8c8;color: #333333;text-align: right;margin-top: 20rpx;font-size: 24rpx;">{{timeDescription(item.createtime)}}</view>
			</view>
			</view>
		</view>
		<tui-nomore text="已经到最底了" backgroundColor="#f7f7f7"></tui-nomore>
	</view>
</template>

<script>
	import {
		getShopShareList
	} from '../../apis'
	export default {
		data() {
			return {
				params: {
					page: 1,
					list_rows: 10
				},
				list: [],
				last_page:''
			}
		},
		onLoad() {
			this.getList()
			uni.setNavigationBarTitle({
				title:'分享记录'
			})
		},
		computed: {
		
		},
		methods: {
			
			timeDescription(str) {
			  const inputDate = new Date(str);
			  const currentDate = new Date();
			  const diffInMilliseconds = currentDate - inputDate;
			
			  const secondsAgo = Math.floor(diffInMilliseconds / 1000);
			  if (secondsAgo < 60) {
			    return '刚刚';
			  }
			
			  const minutesAgo = Math.floor(secondsAgo / 60);
			  if (minutesAgo < 60) {
			    return `${minutesAgo}分钟前`;
			  }
			
			  const hoursAgo = Math.floor(minutesAgo / 60);
			  if (hoursAgo < 24) {
			    return `${hoursAgo}小时前`;
			  }
			
			  const daysAgo = Math.floor(hoursAgo / 24);
			  return `${daysAgo}天前`;
			},
			async getList() {
				let res = await getShopShareList(this.params)
				this.last_page=res.data.last_page
				this.list = [...this.list, ...res.data.data]
			}
		},
		onReachBottom() {
			if (this.last_page>this.params.page) {
				this.params.page++
				this.getList()
			}
		}
	}
</script>

<style lang="scss" scoped>

</style>